/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Tuan Long
 */
@Entity
@Table(name = "EventComment")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "EventComment.findAll", query = "SELECT e FROM EventComment e"),
    @NamedQuery(name = "EventComment.findById", query = "SELECT e FROM EventComment e WHERE e.id = :id"),
    @NamedQuery(name = "EventComment.findByComment", query = "SELECT e FROM EventComment e WHERE e.comment = :comment"),
    @NamedQuery(name = "EventComment.findByCommented", query = "SELECT e FROM EventComment e WHERE e.commented = :commented")})
public class EventComment implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "Id")
    private Integer id;
    @Size(max = 2147483647)
    @Column(name = "Comment")
    private String comment;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Commented")
    @Temporal(TemporalType.TIMESTAMP)
    private Date commented;
    @JoinColumn(name = "EventId", referencedColumnName = "EventId")
    @ManyToOne(optional = false)
    private EventLibrary eventId;
    @JoinColumn(name = "Username", referencedColumnName = "Username")
    @ManyToOne(optional = false)
    private Employee username;

    public EventComment() {
    }

    public EventComment(Integer id) {
        this.id = id;
    }

    public EventComment(Integer id, Date commented) {
        this.id = id;
        this.commented = commented;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Date getCommented() {
        return commented;
    }

    public void setCommented(Date commented) {
        this.commented = commented;
    }

    public EventLibrary getEventId() {
        return eventId;
    }

    public void setEventId(EventLibrary eventId) {
        this.eventId = eventId;
    }

    public Employee getUsername() {
        return username;
    }

    public void setUsername(Employee username) {
        this.username = username;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EventComment)) {
            return false;
        }
        EventComment other = (EventComment) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.EventComment[ id=" + id + " ]";
    }
    
}
